﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MyFloridaHouse.libSvUtilities.CustomColors;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace MyFloridaHouse.libSvOpenDistricts.Districts
{
    public class DistrictColors
    {

        public DistrictColors(string colorType)
        {
            // set up a globally available reference
            _districtColorsInstance = this;

            if (colorType == "PREDEFINED")
                districtColors = new PreDefinedColors();
            else 
                //(colorType == "WEBSAFE")
                districtColors = new WebSafeColors();
        }


        private static DistrictColors _districtColorsInstance;
        public static DistrictColors districtColorsInstance
        {
            get { return _districtColorsInstance; }
            set { _districtColorsInstance = value; }
        }

        private double _opacity = .8;
        public double opacity 
        {
            get { return _opacity; }
            set { _opacity = value; }
        }

        private ICustomColors districtColors;

        public static SolidColorBrush GetBrushFromIndex(int districtIndex)
        {
            if (DistrictColors.districtColorsInstance == null)
            {
                return new SolidColorBrush(Colors.Magenta);
            }
            if (DistrictColors.districtColorsInstance.districtColors == null)
            {
                return new SolidColorBrush(Colors.Orange);
            }
            return new SolidColorBrush(DistrictColors.districtColorsInstance.districtColors.GetColorFromIndex(districtIndex, DistrictColors.districtColorsInstance.opacity));
        }

        public static Color GetColorFromIndex(int districtIndex)
        {
            return DistrictColors.districtColorsInstance.districtColors.GetColorFromIndex(districtIndex, DistrictColors.districtColorsInstance.opacity);
        }


    }
}
